<template>
    <div class="index">
      <div class="titleBox">
        <img src="./img/hlogo.png" alt="">
      </div>
      <div class="box">
        <button class="return-button" @click="returnToLogin">返回登录</button>
        <h2>快速注册</h2>
        <form @submit.prevent="login" class="login-form">
          <div class="form-group">
            <input type="password" v-model="email" placeholder="请输入邮箱" required>
          </div>  
          <div class="form-group">
            <input type="text" v-model="Captcha" placeholder="请输入获取的验证码" required>
          </div>
          <div class="form-group">
            <input type="password" v-model="password" placeholder="请输入密码" required>
          </div>
          <div class="form-group">
            <input type="cpw" v-model="cpw" placeholder="请确认密码" required>
          </div>
          <div class="change">选择用户类型（可多选）：</div>
          <div class="form-1">
            <label for="autoLogin">
              <input type="checkbox" id="autoLogin"> 家长
            </label>
            <label for="autoLogin">
              <input type="checkbox" id="autoLogin"> 大学生
            </label>
            <label for="autoLogin">
              <input type="checkbox" id="autoLogin"> 中小学生
            </label>
          </div>
          
          <button type="submit">立即注册</button>
        </form>
        <div v-if="error" class="error-message">{{ error }}</div>
      </div>
    </div>
  </template>
  
    
  <script setup lang="ts">
  import { ref } from 'vue';

  const email = ref('');
  const captcha = ref('');
  const password = ref('');
  const cpw = ref('');
  const error = ref('');

  const login = () => {
    if (!email.value || !captcha.value || !password.value || !cpw.value) {
      error.value = '请填写完整的表单';
      return;
    }

    if (password.value !== cpw.value) {
      error.value = '两次输入的密码不一致';
      return;
    }

    console.log('表单提交成功');
  }
</script>

    
    <style scoped>
    .index {
      width: 1490px;
      height: 708px;
      background: linear-gradient(to bottom, #0e79c0 50%, #fff 50%);
      display: flex;
      justify-content: center;
      align-items: center;
      position: absolute;
      top:0;
      left:0;
}
    
    .box {
    width: 425px;
    height: 500px;
    padding: 10px;
    background-color: rgba(255, 255, 255, 0.9);
    border-radius: 10px; 
    border: 2px solid #ccc; 
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); 
    color: #0e79c0;
  }

  
    
    .login-form {
      display: flex;
      flex-direction: column;
    }
    
    .form-group {
      margin-bottom: 20px;
    }
    
    input[type="text"],
    input[type="password"],
    button {
      padding: 10px;
      font-size: 16px;
      border: 1px solid #ccc;
      border-radius: 3px;
    }
    
    button {
    width: 200px; 
    padding: 10px; 
    font-size: 16px;
    border: none;
    border-radius: 30px;
    background-color: #007bff;
    color: #fff;
    cursor: pointer;
    transition: background-color 0.3s;
    margin-left: 70px; 
  }
    
    
    button:hover {
      background-color: #0056b3;
    }
    
    .error-message {
      color: red;
      margin-top: 10px;
    }
  
    .titleBox img {
    width: 70px;
    height: 70px;
  }
  
    .titleBox {
    margin-bottom: 480px; 
  }
  
    .form {
      color:#707070;
      font-size: 12px;
    }
    
    label {
    margin-left: -300px; 
  }

  .change {
  padding-right: 180px;
}

.form-1 {
  display: flex;
  justify-content: space-between;
}

.form-1 label {
  flex: 1; 
  margin-left: 5px
}

.return-button {
  position: absolute;
  top: 10px;
  right: 10px;
  background-color: transparent;
  border: none;
  color: #7a828b;
  cursor: pointer;
}

.return-button:hover {
  text-decoration: underline;
}

</style>
    